const { mock } = require('mockjs')
const { common, department } = require('../src/utils/userTypes')
const { commonUserPermission, trafficDepartmentPermission } = require('../src/utils/permissions')
const User = require('../src/models/User')

const { userInfo } = mock({
  'userInfo|20-30': [
    {
      userName: '@first@last',
      loginPwd: '@string(8,12)',
      'isCommon|8-2': true,
      userType: function () {
        return this.isCommon ? common : department // 80% 概率为 'common'
      },
      permission: function () {
        return this.userType === department ? trafficDepartmentPermission : commonUserPermission
      },
    },
  ],
})

User.bulkCreate(userInfo)
